package net.daum.codegen.domain;

import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;

public class Table extends BaseObject {
	private static final long serialVersionUID = -5811710899974348982L;
	private String name;
	private String schema;
	private List<Column> columnList = Lists.newArrayList();
	private List<Column> systemColumnList = Lists.newArrayList();
	private List<Column> noneSystemColumnList = Lists.newArrayList();
	private List<Column> primaryColumnList = Lists.newArrayList();
	private List<Column> nonePrimaryColumnList = Lists.newArrayList();
	private String packageName;
		
	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	public List<Column> getColumnList() {
		return columnList;
	}

	public void setColumnList(List<Column> columnList) {
		this.columnList = columnList;

		this.systemColumnList = new ArrayList<Column>(Collections2.filter(
				this.columnList, new Predicate<Column>() {
					public boolean apply(Column column) {
						return column.isSystemColumn();
					}
				}));
		this.noneSystemColumnList = new ArrayList<Column>(
				Collections2.filter(this.columnList,
						new Predicate<Column>() {
							public boolean apply(Column column) {
								return !column.isSystemColumn();
							}
						}));
		this.primaryColumnList = new ArrayList<Column>(Collections2.filter(
				this.columnList, new Predicate<Column>() {
					public boolean apply(Column column) {
						return column.isPrimary();
					}
				}));
		this.nonePrimaryColumnList = new ArrayList<Column>(
				Collections2.filter(this.columnList,
						new Predicate<Column>() {
							public boolean apply(Column column) {
								return column.isPrimary();
							}
						}));
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSchema() {
		return schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}

	public List<Column> getSystemColumnList() {
		return systemColumnList;
	}

	public void setSystemColumnList(List<Column> systemColumnList) {
		this.systemColumnList = systemColumnList;
	}

	public List<Column> getNoneSystemColumnList() {
		return noneSystemColumnList;
	}

	public void setNoneSystemColumnList(List<Column> noneSystemColumnList) {
		this.noneSystemColumnList = noneSystemColumnList;
	}

	public List<Column> getPrimaryColumnList() {
		return primaryColumnList;
	}

	public void setPrimaryColumnList(List<Column> primaryColumnList) {
		this.primaryColumnList = primaryColumnList;
	}

	public List<Column> getNonePrimaryColumnList() {
		return nonePrimaryColumnList;
	}

	public void setNonePrimaryColumnList(List<Column> nonePrimaryColumnList) {
		this.nonePrimaryColumnList = nonePrimaryColumnList;
	}	
}